/****************************************************************************************
* Copyright 2018
*
* @file:zero_value.h
* @author:waboo
* @date:2018-11-1
* @brief:this file defined the base value types  zero values;
*
* history:
*
*
*******************************************************************************************/
#pragma once
#include <float.h>

GEO_ALG_BEGIN_NAMESPACE

template<class T>
struct ZeroType {

};

template<>
struct ZeroType <float> {
    static float zero_value() {
        return 1e-4f;
    }

    static bool is_zero(float v) {
        return fabs(v) <= 1e-4f;
    }
};

template<>
struct ZeroType <double> {
    static double zero_value() {
        return 1e-7;
    }

    static bool is_zero(double v) {
        return fabs(v) <= 1e-7;
    }
};

template<>
struct ZeroType <short> {
    static short zero_value() {
        return 0;
    }

    static bool is_zero(short v) {
        return v == 0;
    }
};

template<>
struct ZeroType <int> {
    static int zero_value() {
        return 0;
    }

    static bool is_zero(int v) {
        return v == 0;
    }
};

template<>
struct ZeroType <long> {
    static long zero_value() {
        return 0;
    }
    static bool is_zero(long v) {
        return v == 0;
    }
};

template<>
struct ZeroType <__int64> {
    static __int64 zero_value() {
        return 0;
    }
    static bool is_zero(__int64 v) {
        return v == 0;
    }
};

GEO_ALG_END_NAMESPACE